{% extends "ui/base-devices.html" %}
{% load url from future %}
{% load i18n icons %}

{% block content %}
{% if not asset_required %}
<div class="alert alert-info">
  {% trans "This type of device does not require an asset." %}
</div>
{% elif asset_required and form %}
<div class="well well-small">
  {% block trans %}
  <p>Select {% if asset %}a new {% else %}an {% endif %}asset for this device (by serial number, barcode or model):</p>
  {% endblock %}
  <form class="form-inline choose-asset-form" method="POST">
    {% csrf_token %}
    <div class="control-group {% if form.asset.errors %}error{% endif %}">
      {{ form.asset }}
      {% if form.asset.errors %}
      <span class="help-inline">
        {% for error in form.asset.errors %}
        {{ error }}&nbsp;
        {% endfor %}
      </span>
      {% endif %}
    </div>
    <div class="control-group">
      <button type="submit" class="btn btn-primary">{% icon 'fugue-tick' %}&nbsp;Save</button>
    </div>
  </form>
</div>  <!-- /well -->
{% endif %}
{% if asset %}
<div class="row-fluid">
  <div class="span6">
    <h3>{% trans "Base info" %}</h3>
    <table class="table table-striped table-bordered table-condensed">
      {% include 'ui/device_asset_property.html' with name='SN' value=asset.sn %}
      {% include 'ui/device_asset_property.html' with name='Barcode' value=asset.barcode %}
      {% include 'ui/device_asset_property.html' with name='Status' value=asset.status %}
      {% include 'ui/device_asset_property.html' with name='Production use date' value=asset.production_use_date %}
      {% include 'ui/device_asset_property.html' with name='Category' value=asset.category %}
      {% include 'ui/device_asset_property.html' with name='Remarks' value=asset.remarks %}
    </table>
    <h3>{% trans "Hardware" %}</h3>
    <table class="table table-striped table-bordered table-condensed">
      {% include 'ui/device_asset_property.html' with name='Manufacturer' value=asset.manufacturer %}
      {% include 'ui/device_asset_property.html' with name='Model' value=asset.model %}
      {% include 'ui/device_asset_property.html' with name='Slots (for blade centers)' value=asset.slots %}
      {% include 'ui/device_asset_property.html' with name='Size in units' value=asset.size %}
    </table>
    <h3>{% trans "Location" %}</h3>
    <table class="table table-striped table-bordered table-condensed">
      {% include 'ui/device_asset_property.html' with name='Warehouse' value=asset.warehouse %}
      {% include 'ui/device_asset_property.html' with name='U level' value=asset.u_level %}
      {% include 'ui/device_asset_property.html' with name='U height' value=asset.u_height %}
    </table>
  </div>
  <div class="span6">
    <h3>{% trans "Accounting data" %}</h3>
    <table class="table table-striped table-bordered table-condensed">
      {% include 'ui/device_asset_property.html' with name='Invoice no' value=asset.invoice_no %}
      {% include 'ui/device_asset_property.html' with name='Order no' value=asset.order_no %}
      {% include 'ui/device_asset_property.html' with name='Niw' value=asset.niw %}
      {% include 'ui/device_asset_property.html' with name='Source' value=asset.source %}
      {% include 'ui/device_asset_property.html' with name='Price' value=asset.price %}
      {% include 'ui/device_asset_property.html' with name='Support price' value=asset.support_price %}
      {% include 'ui/device_asset_property.html' with name='Support type' value=asset.support_type %}
      {% include 'ui/device_asset_property.html' with name='Support period in months' value=asset.support_period %}
      {% include 'ui/device_asset_property.html' with name='Support void reporting' value=asset.support_void_reporting bool_value=1 %}
      {% include 'ui/device_asset_property.html' with name='Provider' value=asset.provider %}
      {% include 'ui/device_asset_property.html' with name='Request date' value=asset.request_date %}
      {% include 'ui/device_asset_property.html' with name='Provider order date' value=asset.provider_order_date %}
      {% include 'ui/device_asset_property.html' with name='Delivery date' value=asset.delivery_date %}
      {% include 'ui/device_asset_property.html' with name='Invoice date' value=asset.invoice_date %}
      {% include 'ui/device_asset_property.html' with name='Deprecation rate' value=asset.deprecation_rate %}
      {% include 'ui/device_asset_property.html' with name='Deprecated' value=asset.is_deprecated bool_value=1 %}
    </table>

    <h3>{% trans "Supports Data" %}</h3>
    <table class="table table-striped table-bordered table-condensed">
      {% include 'ui/device_asset_property.html' with name='Required support' value=asset.required_support bool_value=1 %}
      <tr>
        <td><strong>{% trans "Assigned supports" %}</strong></td>
        <td>
          <ul>
            {% for support in asset.supports %}
            <li><a href="{{ support.url}}">{{ support.name }}</a></li>
            {% endfor %}
          </ul>
        </td>
      </tr>
    </table>

  </div>
</div>
<div class="row-fluid">
  <a href="{{ asset.url }}" class="btn btn-primary">{% icon 'fugue-briefcase--pencil' %}&nbsp;{% trans "Edit this asset" %}</a>
</div>
{% endif %}
{% endblock content %}

